﻿using System;
using System.Windows.Forms;
using EmbeddedSharp.Core;

namespace Zove.Desktop.Function
{
    public class MessageBoxNode : FuncNode
    {
        public MessageBoxNode() :
            base("messageBox")
        {
        }

        public override object Evaluate()
        {
            if (Parameters.Count < 1)
            {
                throw new ArgumentException(
                    "usage: messageBox(message)");
            }

            string message = Convert.ToString(
                Parameters[0].Evaluate());
            if (MessageBox.Show(
                message) == DialogResult.OK)
            {
                return "ok";
            }

            return "cancel";
        }
    }
}
